package com.CST.controller.zx;


import com.CST.bo.zx.ApprovalUserBO;
import com.CST.common.api.ResultObject;
import com.CST.entity.zx.ZxAuth;
import com.CST.service.cb.IBdSysUserService;
import com.CST.service.zx.IZxAuthService;
import com.CST.util.PageHelperTool;
import io.swagger.annotations.*;

import java.util.*;

import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ly
 * @since 2023-03-28
 */
@Api(tags = {"审批用户"})
@RestController
@RequestMapping("/zxAuth")
public class ZxAuthController {

    @Autowired
    private IZxAuthService targetService;

    @Resource
    private IBdSysUserService bdSysUserService;
    @PostMapping("/getAllUser")
    @ApiOperation("查询可以新增的用户")
    public ResultObject getAllUser(@RequestBody ApprovalUserBO approvalUserBO) {
        List<ZxAuth> list = bdSysUserService.getAllUser(approvalUserBO);
        return ResultObject.success(PageHelperTool.excutePageInfo(list,approvalUserBO.getPageNo(), approvalUserBO.getPageSize()));
    }

    @PostMapping("/insertZxAuth")
    @ApiOperation("新增审批用户")
    public ResultObject insertZxAuth(@RequestBody ZxAuth zxAuth) {
        boolean save = targetService.save(zxAuth);
        return save? ResultObject.success("保存成功"): ResultObject.failed("保存失败");
    }

    @GetMapping("/getAllHandleUser")
    @ApiOperation("查询所有可以审批用户")
    public ResultObject getAllHandleUser() {
        List<ZxAuth> list = targetService.list();
        return ResultObject.success(list);
    }
}

